
/**
 *The Connection thread 
 * 
 * @author Ross Delinger
 * @version 10Jan 2001
 */
package helixoide.irc;
import java.io.*;


import helixoide.Util;
import helixoide.otherMain;
import helixoide.irc.serverType.unreal32;
public class ConnectionThread implements Runnable
{
    BufferedReader ircIn;
    BufferedWriter ircOut;
    BufferedWriter otherOut;
    otherMain main = null;
    unreal32 handoff = null;
    public ConnectionThread(BufferedReader in,BufferedWriter out,Object mainT,unreal32 proto)
    {
        main = (otherMain)mainT;
        ircIn = in;
        ircOut = out;
        handoff = proto;
            
    }
    public void run()
    {
        String input = "";
        for(; ;)
        {
            try
            {
                input = ircIn.readLine();
                if(input!=null)
                {
                	handoff.incomingMessage(input);
                }
                if(Thread.interrupted())
                {
                    throw new InterruptedException();
                }
            }
            catch(IOException e)
            {
                e.printStackTrace();
                break;
            }
            catch(InterruptedException e)
            {
                e.printStackTrace();
                break;
            }
        }
        Util.getThreads().remove(Thread.currentThread());
        main.die();
        
    }
                
            
        
}
